package com.itheima.bigdecimal;

import java.math.BigDecimal;
import java.util.Scanner;

public class MyBigDecimalDemo1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要运算的第一个数");
        String num1 = sc.next();
        System.out.println("请输入要运算的第二个数");
        String num2 = sc.next();
        BigDecimal bd1 = new BigDecimal(num1);
        BigDecimal bd2 = new BigDecimal(num2);
        while (true) {
            System.out.println("请输入要进行的运算操作[1. 加法； 2: 减法; 3: 乘法; 4: 除法; 5: 退出]");
            String choice = sc.next();
            switch (choice) {
                case "1":
                    System.out.println(num1 + "+" + num2 + "=" + (bd1.add(bd2)));
                    break;
                case "2":
                    System.out.println(num1 + "-" + num2 + "=" + (bd1.subtract(bd2)));
                    break;
                case "3":
                    System.out.println(num1 + "*" + num2 + "=" + (bd1.multiply(bd2)));
                    break;
                case "4":
                    System.out.println(num1 + "/" + num2 + "=" + (bd1.divide(bd2)));
                    break;
                case "5":
                    System.out.println("感谢您的使用");
                    return;
            }
        }

    }
}
